package org.iteam.bank.mina.utils;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

public class IpUtils {
	@SuppressWarnings("unchecked")
	public static String ip(HttpServletRequest request) {

		// Enumeration<String > names=request.getHeaderNames();
		// while (names.hasMoreElements()) {
		// String string = (String) names.nextElement();
		// System.out.println(string+":"+request.getHeader(string));
		// }

		Enumeration<String> enumeration = request.getHeaders("x-forwarded-for");
		if (enumeration != null && enumeration.hasMoreElements()) {
			return enumeration.nextElement();
		}
		return request.getRemoteHost();
	}
}
